package com.ruoyi.kk.destination.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kk.destination.domain.KkHikingDestination;
import com.ruoyi.kk.destination.service.IKkHikingDestinationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 徒步目的地信息Controller
 * 
 * @author kk
 * @date 2025-06-09
 */
@RestController
@RequestMapping("/kk/destination")
public class KkHikingDestinationController extends BaseController
{
    @Autowired
    private IKkHikingDestinationService kkHikingDestinationService;

    /**
     * 查询徒步目的地信息列表
     */
    @PreAuthorize("@ss.hasPermi('kk:destination:list')")
    @GetMapping("/list")
    public TableDataInfo list(KkHikingDestination kkHikingDestination)
    {
        startPage();
        List<KkHikingDestination> list = kkHikingDestinationService.selectKkHikingDestinationList(kkHikingDestination);
        return getDataTable(list);
    }

    /**
     * 导出徒步目的地信息列表
     */
    @PreAuthorize("@ss.hasPermi('kk:destination:export')")
    @Log(title = "徒步目的地信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KkHikingDestination kkHikingDestination)
    {
        List<KkHikingDestination> list = kkHikingDestinationService.selectKkHikingDestinationList(kkHikingDestination);
        ExcelUtil<KkHikingDestination> util = new ExcelUtil<KkHikingDestination>(KkHikingDestination.class);
        util.exportExcel(response, list, "徒步目的地信息数据");
    }

    /**
     * 获取徒步目的地信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kk:destination:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kkHikingDestinationService.selectKkHikingDestinationById(id));
    }

    /**
     * 新增徒步目的地信息
     */
    @PreAuthorize("@ss.hasPermi('kk:destination:add')")
    @Log(title = "徒步目的地信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KkHikingDestination kkHikingDestination)
    {
        kkHikingDestination.setCreatedById(getUserId());
        kkHikingDestination.setCreatedBy(getNickname());
        kkHikingDestination.setCreatedTime(DateUtils.getCurrDate());
        return toAjax(kkHikingDestinationService.insertKkHikingDestination(kkHikingDestination));
    }

    /**
     * 修改徒步目的地信息
     */
    @PreAuthorize("@ss.hasPermi('kk:destination:edit')")
    @Log(title = "徒步目的地信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KkHikingDestination kkHikingDestination)
    {
        kkHikingDestination.setUpdatedById(getUserId());
        kkHikingDestination.setUpdatedBy(getNickname());
        kkHikingDestination.setUpdatedTime(DateUtils.getCurrDate());
        return toAjax(kkHikingDestinationService.updateKkHikingDestination(kkHikingDestination));
    }

    /**
     * 删除徒步目的地信息
     */
    @PreAuthorize("@ss.hasPermi('kk:destination:remove')")
    @Log(title = "徒步目的地信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kkHikingDestinationService.deleteKkHikingDestinationByIds(ids));
    }
}
